using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;

public class PlayerItemDrop : ItemDrop
{
    [Header("Player's drop")]
    [SerializeField] private float chanceToLooseItems;
    [SerializeField] private float chanceToLooseMatericals;
    public override void GenerateDrop()
    {
        List<InventoryItem> matericalsToUnequip = new List<InventoryItem>();
        List<InventoryItem>itemsToUnequip=new List<InventoryItem>();
        List<InventoryItem> currentEquipment = Inventory.instance.GetEquipmentList();
        foreach(var item in currentEquipment)
        {
            if(Random.Range(0,100)<chanceToLooseItems)
            {
                DropItem(item.data);
                itemsToUnequip.Add(item);

            }
        }
        for(int i=0;i<itemsToUnequip.Count;i++)
        {
            Inventory.instance.UnequipItem(itemsToUnequip[i].data as ItemData_Equipment);

        }
        foreach(var item in Inventory.instance.GetStashList())
        { 
            if(Random.Range(0,100)<chanceToLooseMatericals)
            {
                DropItem(item.data);
                matericalsToUnequip.Add(item);


            }
        }
        for(int i=0;i<matericalsToUnequip.Count;i++)
        {
            Inventory.instance.RemoveItem(matericalsToUnequip[i].data);

        }
    }
}
